﻿/*
 * Created by SharpDevelop.
 * User: kktn
 * Date: 04.07.2006
 * Time: 09:22
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */

using System;
using System.Collections.Generic;
using System.Drawing;
using TagTool.GraphicTypes;

namespace TagTool.Components
{
	/**
	 * The Colortable provides the colors of the
	 * connections for the various datatypes 
	 * used.
	 * The Colortable is a singleton.
	 */
	public class ColorTable
	{
		private class Col
		{
			public System.Drawing.Color color;
			public Col(System.Drawing.Color color)
			{
				this.color = color;
			}
		}
		
		private SortedList<String, Col> colors = new SortedList<String, Col>();
		private static ColorTable instance;
		
		public static ColorTable Instance
		{
			get 
			{ 
				if (instance == null)
				{
					instance = new ColorTable();
					instance.colors.Add(typeof(double).FullName, new Col(System.Drawing.Color.Black));
					instance.colors.Add(typeof(int).FullName, new Col(System.Drawing.Color.Gray));
					instance.colors.Add(typeof(bool).FullName, new Col(System.Drawing.Color.Blue));
					instance.colors.Add(typeof(PointD).FullName, new Col(System.Drawing.Color.Cyan));
					instance.colors.Add(typeof(TagTool.GraphicTypes.Color).FullName, new Col(System.Drawing.Color.DeepPink));
				}
				return instance; 
			}
		}
		
		private ColorTable()
		{
		}
		
		public System.Drawing.Color GetColor(Type type)
		{
			String s = type.FullName;
			if (colors.ContainsKey(s))
			{
				return colors[s].color;
			}
			return  System.Drawing.Color.Black;
		}
	}
}
